package com.csc.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.csc.dao.UserDao;
import com.csc.domain.User;

@Service
public class UserServiceImpl implements UserService {

	@Autowired
	private UserDao userDao;

	// ThanhBinh
	public User checkLogin(String userName, String password) {

		List<User> users = userDao.getAllUsers();
		User user = null;
		for (User userRole : users) {
			if (userRole.getUserName().equals(userName)
					&& userRole.getPassword().equals(password)) {
				user = userRole;
				break;
			}
		}
		return user;
	}

	// TrangNguyen
	public User getUserById(int userId) {
		return userDao.getUserById(userId);
	}
}
